package com.yidu.ladder.delivery.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yidu.ladder.base.domain.RipareaStaffVo;
import com.yidu.ladder.base.domain.Staff;
import com.yidu.ladder.base.domain.StaffVo;
import com.yidu.ladder.delivery.dao.WorkorderDao;
import com.yidu.ladder.delivery.domain.Workorder;
import com.yidu.ladder.delivery.domain.WorkorderVo;
import com.yidu.ladder.delivery.service.WorkorderService;
@Service
public class WorkorderServiceimpl implements WorkorderService{
	@Autowired
	private WorkorderDao  workorderDao;
	
	public WorkorderDao getWorkorderDao() {
		return workorderDao;
	}
	public void setWorkorderDao(WorkorderDao workorderDao) {
		this.workorderDao = workorderDao;
	}
	public WorkorderServiceimpl() {
		super();
	}
	public WorkorderServiceimpl(WorkorderDao workorderDao) {
		super();
		this.workorderDao = workorderDao;
	}
	@Override
	public Map<String, Object> pageQueryWorkorder(WorkorderVo workorderVo) {
		int page = (workorderVo.getPage() - 1) * workorderVo.getLimit();
		workorderVo.setPage(page);
		List<Workorder> query = workorderDao.pageQueryWorkorder(workorderVo);
		int count = workorderDao.countUserByCriteria(workorderVo);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", count);
		map.put("data", query);
		return map;
	}
	@Override
	public Map<String, Object> pageQuerStaff(StaffVo staffVo) {
		int page = (staffVo.getPage() - 1) * staffVo.getLimit();
		staffVo.setPage(page);
		List<Staff> query = workorderDao.pageQueryStaff(staffVo);
		int count = workorderDao.countStaffByCriteria(staffVo);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", count);
		map.put("data", query);
		return map;
	}
	@Override
	public Map<String, Object> pgaeQuerStaffs(RipareaStaffVo ripareaStaffVo) {
		int page = (ripareaStaffVo.getPage() - 1) * ripareaStaffVo.getLimit();
		ripareaStaffVo.setPage(page);
		List<Staff> query = workorderDao.findAllStaffByRipAreaId(ripareaStaffVo);
		int count = workorderDao.cuntRipareaStaff(ripareaStaffVo);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", count);
		map.put("data", query);
		return map;
	}
	@Override
	public int updateworkorder(Workorder workorder) {
		return workorderDao.updateworkorder(workorder);
	}
	
	@Override
	public List<Workorder> findWorkorderByBNoId(String businessNoticeId) {
		return workorderDao.findWorkorderByBNoId(businessNoticeId);
	}
}
